<template>
	<view class="pageAll">
		<view v-if="info">
			<view>
				<notPassInfo :info="info" />
			</view>
			<view class="bottomBtnView">
				<button class="bottomBtn" hover-class="subActive" @click="deleteReport">
					删除
				</button>
			</view>
		</view>
		<nonePage v-else />
	</view>
</template>

<script>
	import notPassInfo from '../../../components/foodReport/notPassInfo.vue'
	import nonePage from '../../../components/commonCom/nonePage.vue'
	export default {
		data() {
			return {
				info: {},
			}
		},
		methods: {
			// 删除提报
			deleteReport() {
				this.$api.submissionFileDelete({
					id: this.info.id
				}).then(res => {
					if (res.status) {
						uni.showToast({
							title: '删除提报成功',
						})

						this.$store.commit('setCurrTag', 4)
						this.$store.commit('setSubCurrTag', 2)

						setTimeout(res => {
							uni.switchTab({
								url: '../foodReport/foodReport'
							})
						}, 1500)
					} else {
						uni.showToast({
							title: '操作失败',
							icon: 'none',
						})
					}
				})
			},
			getInfo(id) {
				this.$api.checkedFailMessage({
						id: id
					})
					.then(res => {
						if (res.status) {
							this.info = res.data
						} else {
							this.info = null
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 1500,
							})
						}
					})
					.catch(err => {
						this.info = null
						uni.showToast({
							title: '加载失败',
							icon: 'none',
							duration: 1500,
						})
						setTimeout(() => {
							uni.switchTab({
								url: '../foodReport/foodReport'
							})
						}, 1500)
					})
			}
		},
		components: {
			notPassInfo,
			nonePage,
		},
		onLoad(option) {
			this.getInfo(option.id)
		},
		onShareAppMessage: (options) => {
			// 设置菜单中的转发按钮触发转发事件时的转发内容
			var shareObj = {
				title: "红标HONBIAO", // 默认是小程序的名称(可以写slogan等)
				path: '/pages/indexPage/authorization/authorization', // 默认是当前页面，必须是以‘/’开头的完整路径
				imageUrl: '/static/index/labelRouge.png', //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
				success: (res) => {
					// 转发成功之后的回调
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: () => {
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				}
			};
			return shareObj
		},
	}
</script>

<style scoped>
	.pageAll {
		box-sizing: border-box;
		background-color: #fdf5f3;
		width: 100%;
		height: 100%;
		padding: 0 17upx;
		display: inline-block;
		position: fixed;
	}

	.bottomBtnView {
		margin-top: 40upx;
	}

	.bottomBtn {
		background-color: #ffc8c7;
		font-size: 36upx;
		color: #666666;
		letter-spacing: 10upx;
		text-indent: 10upx;
	}

	.bottomBtn:after {
		border: none;
	}

	.subActive {
		background-color: #F3D6D4;
	}
</style>
